package com.kingyun.gpsinspection.purificationservice.services.iam.innerservice.accessory.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kingyun.gpsinspection.purificationservice.facade.service.iam.accessory.IamEntityTypeProService;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.EntityTypeProperty;
import com.kingyun.gpsinspection.purificationservice.facade.service.jsm.OutEntityTypePropertyService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by yangsy on 2017/2/24.
 */
public class IamEntityTypeProServiceImpl implements IamEntityTypeProService
{

    private static org.slf4j.Logger logger = LoggerFactory.getLogger(IamEntityTypeProServiceImpl.class);

    @Autowired(required = false)

    private OutEntityTypePropertyService outEntityTypePropertyService;
    @Override
    public List<EntityTypeProperty> queryETProperty(String entityTypeId) {
        try {
            return outEntityTypePropertyService.entityTypePropertyList(entityTypeId);
        }catch (Exception e){
            logger.info("查询生产实体类型特性失败"+e.getMessage());
            return null;
        }
    }

    @Override
    public JSONObject jsonObject(String entityTypeId) {
        List<EntityTypeProperty> list = this.queryETProperty(entityTypeId);
        if(list == null || list.size() < 0) return null;
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("rows", JSON.toJSON(list));
        return jsonObject;
    }
}
